<?php 
session_start();
$selectprimemo = mysql_query("SELECT IDMemo,Title,DATE_FORMAT(CreatedDate,'%Y-%m-%d') as CreatedDate FROM list_memo WHERE IDEmployee ='$id_employee'");

?>
<script type="text/javascript">
function onclickAddNewPrivate(els){
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	    {
	        document.getElementById("idprivatememo").innerHTML=xmlhttp.responseText;
	        loadeditor();
	    }
	  }
	var lang = '<?=$_SESSION['lang']?>';
	xmlhttp.open("GET","admin/privatememo/new-private-memo.php?newlang="+lang,true);
	xmlhttp.send();

	function loadeditor(){
        var editor = CKEDITOR.replace("ncontent");
  	  	CKFinder.setupCKEditor(editor, '../ckfinder') ;
	}
}
function onclickback(els){
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	    {
	        document.getElementById("idprivatememo").innerHTML=xmlhttp.responseText;
	    }
	  }
	xmlhttp.open("GET","admin/privatememo/content-private-memo.php",true);
	xmlhttp.send();

}

function processDeletePri(idmemo,idemployee,els)
	{
		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		    {
		        document.getElementById("idprivatememo").innerHTML=xmlhttp.responseText;
		    }
		  }
		var lang = '<?=$_SESSION['lang']?>';
		xmlhttp.open("GET","admin/privatememo/process-delete-privatememo.php?idmemo="+idmemo+"&idemp="+idemployee+"&newlang="+lang,true);
		xmlhttp.send();

		}
function onclickEditPrivateMemo(idmemo,action,els){
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	    {

	        document.getElementById("idprivatememo").innerHTML=xmlhttp.responseText;
	        
	        loadeditor();
	    }
	  }
	var lang = '<?=$_SESSION['lang']?>';
	xmlhttp.open("GET","admin/privatememo/new-private-memo.php?idmemo="+idmemo+"&action="+action+"&newlang="+lang,true);
	xmlhttp.send();

	function loadeditor(){
        var editor = CKEDITOR.replace("ncontent");
  	  	CKFinder.setupCKEditor(editor, '../ckfinder') ;
	}
}

function processPreviewPri(idmemo,els){
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	    {

	        document.getElementById("idprivatememo").innerHTML=xmlhttp.responseText;
	        
	    }
	  }
	var lang = '<?=$_SESSION['lang']?>';
	xmlhttp.open("GET","admin/privatememo/preview-private-memo.php?idmemo="+idmemo+"&newlang="+lang,true);
	xmlhttp.send();
}
</script>


<div id="contains" style="background-color: white;">

	<div class="title"></div>
		
	<div class="body" id="idprivatememo" >

		<div id="board-content">
			<span class="caption-board"><?php echo $l_menu_privatememo?></span>
			<center>
				<img src="images/line1.png" width="100%" /><br /> <br /> <br /> <br />
			</center>
			
			<div class="navigation-button"><a href="#" onclick="onclickAddNewPrivate(this);">
			
				<img src="images/new.png" /></a><div><?php echo $l_addnew?></div>
			</div>
				<br style="clear:both" /><br />
				<table width="100%" style="border: 1px dotted silver;">
					<tr>
						<th width="5%"  style="border-right:  1px dotted silver;border-bottom:  1px dotted silver;"><?php echo $l_no?></th>
						<th width="60%" style="border-right:  1px dotted silver;border-bottom:  1px dotted silver;"><?php echo $l_title?></th>
						<th width="20%" style="border-right:  1px dotted silver;border-bottom:  1px dotted silver;"><?php echo $l_created_date?></th>
						<th width="15%" style="border-bottom:  1px dotted silver;"></th>
						
					</tr>
					
					<?php $i = 0; 
					 while ($row=mysql_fetch_array($selectprimemo)){
					  $i++ ;
					  $idmemo = $row[IDMemo];?>
					<tr>
					<td  style="border-right:  1px dotted silver;border-bottom:  1px dotted silver;"><?php echo $i?></td>
					<td style="border-right:  1px dotted silver;border-bottom:  1px dotted silver;">
						<a href="#" onclick="processPreviewPri('<?=$idmemo?>',this);"><?php echo $row[Title]?></a></td>
					<td style="border-right:  1px dotted silver;border-bottom:  1px dotted silver;"><?php echo $row[CreatedDate]?></td>
					<td style="border-right:  1px dotted silver;border-bottom:  1px dotted silver;">
							<a id="preview" style="text-align: left;margin-left: -25px" href="#"
								onclick="processPreviewPri('<?=$idmemo?>',this);"> 
								<img src="images/view.png" /> </a>
							<a id="preview" style="padding-left:15px;" href="#"
								onclick="onclickEditPrivateMemo('<?=$idmemo?>','edit',this);">
								<img src="images/edit-admin.png" /> </a>
							<a id="preview" style="padding-left: 15px;" href="#" 
								onclick="if(confirm('Are you sure?')){ processDeletePri('<?=$idmemo?>','<?=$id_employee?>',this); return true;}else{return false;}">
								<img src="images/delete-admin.png" /> </a>
					</td>
					</tr>
					<?php }?>
				</table>
			
		</div>
	</div>
</div>
